package com.zhu.ttwords.view.listener;

import android.support.v4.view.ViewPager;
import android.util.Log;

import com.zhu.ttwords.bean.WordBean;
import com.zhu.ttwords.presenter.StudyPresenter;
import com.zhu.ttwords.view.widget.StudyView;

/**
 * Created by KnightYe on 2015/4/5.
 * include some callback listener of ViewPager and StudyView.
 */
public class StudyListener implements ViewPager.OnPageChangeListener, StudyView.OnStudyResultListener {
    StudyPresenter presenter;

    public StudyListener(StudyPresenter presenter) {
        this.presenter = presenter;
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    }

    @Override
    public void onPageSelected(int position) {
        presenter.updatePageIndex(position + 1);
    }

    @Override
    public void onPageScrollStateChanged(int state) {
    }


    @Override
    public void saveExamResult(WordBean bean, boolean flag, int level) {
        presenter.saveExamResult(bean, flag, level);
        Log.d("StudyListener", "level is " + level);
    }

    @Override
    public void saveStudyResult(WordBean bean, boolean flag) {
        presenter.saveStudyResult(bean, flag);
    }

}
